<?php 
class Taction extends AppModel {


	var $name = 'Taction';
	var $useTable = 'taction';
	var $primaryKey = "id";

	/**
     * auto collect the actions
     * @param string $action_name action name
     * @return
     */
	function action_collect($action_name) {
		if ( empty($action_name)) {
			return FALSE;
		}
		$c = $this->findCount("upper(f_action) = '".strtoupper($action_name)."'");
		if (0 == $c) {
			$data = Array("id"=>false,"f_action"=>$action_name);
			$this->save($data);
		}
	}
	/**
	 * get ActionId By Name
	 *
	 * @param string $action_name action name
	 * @return int
	 */
	function getActionIdByName($action_name){
		if ( empty($action_name)) {
			return FALSE;
		}
		$action_id = $this->field('id',"upper(f_action) = '".strtoupper($action_name)."'");
		return $action_id;
	}
}
?>
